package rad.framework.mda.generator.template.main.webapp;

import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.*;
import java.util.*;
import rad.framework.mda.generator.util.*;

public class Excel
{
  protected static String nl;
  public static synchronized Excel create(String lineSeparator)
  {
    nl = lineSeparator;
    Excel result = new Excel();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<ui:composition " + NL + "\txmlns:ui=\"http://java.sun.com/jsf/facelets\"" + NL + "\txmlns:f=\"http://java.sun.com/jsf/core\"" + NL + "\txmlns:e=\"http://jboss.com/products/seam/excel\"" + NL + "\ttemplate=\"#{theme.excel}\">" + NL + "\t" + NL + "\t<ui:param name=\"title\" value=\"#{messages['";
  protected final String TEXT_2 = "']}\"/>" + NL + "\t<ui:param name=\"type\" value=\"";
  protected final String TEXT_3 = "\"/>" + NL + "\t<ui:param name=\"finder\" value=\"#{";
  protected final String TEXT_4 = "Finder}\"/>" + NL + "\t<ui:param name=\"result\" value=\"#{";
  protected final String TEXT_5 = "Finder.reportResult}\"/>" + NL + "" + NL + "</ui:composition>";
  protected final String TEXT_6 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
Class uml2Class = (Class) argument;
String uncapClassName = NameHelper.getUncapName(uml2Class);
String capClassName = NameHelper.getCapName(uml2Class);

    stringBuffer.append(TEXT_1);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_2);
    stringBuffer.append(capClassName);
    stringBuffer.append(TEXT_3);
    stringBuffer.append(uncapClassName);
    stringBuffer.append(TEXT_4);
    stringBuffer.append(uncapClassName);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(TEXT_6);
    return stringBuffer.toString();
  }
}
